#include<stdio.h>

int york(int a,int b)
{
	int t;
	while(a%b)
	{
		t=a%b;
		a=b;
		b=t;
	}
	return b;
}

int main()
{
	int a=0,b=0;
	scanf("%d %d",&a,&b);
	printf("%d",york(a,b));
	return 0;
}
